#include "cputest.h"

// clock count base (20+1)
TEST(test301, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302a, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302b, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302c, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302d, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302e, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm4 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302f, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm1 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
// "paddb %%mm1, %%mm2" can be moved freely up
TEST(test302g, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm1, %%mm2 \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
// "paddb %%mm1, %%mm0" can be moved freely up
TEST(test302h, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm1, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302i, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm0, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302j, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm1, %%mm1 \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
// actually, if you move "movl %%ecx, 8(%%esi)" down, then the first one increases by 2
// "movq %%mm0, 8(%%esi)" can be moved freely up
TEST(test304, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movl %%ecx, 8(%%esi) \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movq 8(%%esi), %%mm0 \n\t" \
	"nop \n\t" \
	"movq %%mm0, 8(%%esi) \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movl 8(%%esi), %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )
test301: 21.269690
test302a: 31.432013
test302b: 31.435615
test302c: 31.465410
test302d: 31.464147
test302e: 32.477215
test302f: 32.481902
test302g: 32.456424
test302h: 32.440260
test302i: 32.454481
test302j: 32.459526
test304: 26.386014
